home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q0429.dms / q0429.adf / libshade / builtin.c next >
C/C++ Source or Header  |  1991-08-08  |  1KB  |  79 lines

  1. /*
  2.  * builtin.c
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb, Rod G. Bogart
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  * 
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * $Id: builtin.c,v 4.0 91/07/17 14:45:00 kolb Exp Locker: kolb $
  17.  *
  18.  * $Log:    builtin.c,v $
  19.  * Revision 4.0  91/07/17  14:45:00  kolb
  20.  * Initial version.
  21.  * 
  22.  */
  23.  
  24. #include "rayshade.h"
  25.  
  26. Float
  27. SumExpr(a, b)
  28. Float a, b;
  29. {
  30.     return a + b;
  31. }
  32. Float
  33. DiffExpr(a, b)
  34. Float a, b;
  35. {
  36.     return a - b;
  37. }
  38.  
  39. Float
  40. MultExpr(a, b)
  41. Float a, b;
  42. {
  43.     return a * b;
  44. }
  45. Float
  46. DivideExpr(a, b)
  47. Float a, b;
  48. {
  49.     return a / b;
  50. }
  51.  
  52. Float
  53. ModExpr(a, b)
  54. Float a, b;
  55. {
  56.     return (Float)((int)a % (int)b);
  57. }
  58.  
  59. Float
  60. NegateExpr(a)
  61. Float a;
  62. {
  63.     return -a;
  64. }
  65.  
  66. Float
  67. LinearTime(starttime, startval, endtime, endval)
  68. Float starttime, endtime, startval, endval;
  69. {
  70.     if (TimeExpr->value < starttime)
  71.         return startval;
  72.     if (TimeExpr->value > endtime)
  73.         return endval;
  74.     if (equal(endtime, starttime))
  75.         return startval;
  76.     return startval + (endval - startval) * 
  77.         (TimeExpr->value - starttime) / (endtime - starttime);
  78. }
  79.